﻿using MediatR;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.API.Applications.Command.SlaughterCommand;
using Traceability.Domain;
using Traceability.ErrorCode;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;

namespace Traceability.API.Controllers
{
    /// <summary>
    /// 屠宰信息 控制器——API
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SlaughterController : ControllerBase
    {
        private readonly IMediator mediator;

        public SlaughterController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 屠宰基础信息添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> SlaughterAdd(SlaughterAddCommand command)
        {
            return await this.mediator.Send(command);
        }


        /// <summary>
        /// 屠宰基础信息查询
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<Slaughter_Information>> SlaughterQuery([FromQuery]SlaughterQueryCommand command)
        {

            return this.mediator.Send(command);
        }

        /// <summary>
        /// 屠宰企业信息添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> SlaughterHouseAdd(SlaughterHouseAddCommand command)
        {
            return await mediator.Send(command);
        }


        /// <summary>
        /// 屠宰企业信息查询
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<Slaughter_House>> SlaughterHouseQuery([FromQuery]SlaughterHouseQueryCommand command)
        {
            return mediator.Send(command);
        }
    }
}
